﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace CustomerManager.Core
{
    public class Tools
    {  
        //http://www.codeproject.com/KB/validation/Valid_Email_Addresses.aspx
        public static readonly Regex emailRegex = new Regex(@"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" +
                  @"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" +
                  @".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$");

        /// <summary>
        /// Eldönti, hogy az átadott string email formátumú szöveget tartalmaz-e.
        /// </summary>
        /// <param name="email">Ellenörizendő szöveg.</param>
        /// <returns></returns>
        public static bool IsEmail(string email)
        {
            if (String.IsNullOrEmpty(email)) return false;

            if (emailRegex.IsMatch(email))
                return (true);
            else
                return (false);
        }
    }
}
